package com.servletspringboot.config;

import com.servletspringboot.listener.ManualCreateListener;
import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.EventListener;

@Configuration
public class ListenerConfig {

    @Bean
    public ServletListenerRegistrationBean<EventListener> createListenerAndRegister(){
        ServletListenerRegistrationBean<EventListener> bean = new ServletListenerRegistrationBean<>();

        ManualCreateListener manualCreateListener = new ManualCreateListener();

        bean.setListener(manualCreateListener);

        //设置启动顺序
        bean.setOrder(3);

        return bean;
    }
}
